package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.EventSurgery;
import com.ruoyi.manage.service.IEventSurgeryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
/**
 * 手术事件Controller
 * 
 * @author zww
 * @date 2025-07-01
 */
@Api("手术事件")
@RestController
@RequestMapping("/manage/surgeryevent")
public class EventSurgeryController extends BaseController
{
    @Autowired
    private IEventSurgeryService eventSurgeryService;

    /**
     * 查询手术事件列表
     */
    @ApiOperation("查询手术事件列表")
    @PreAuthorize("@ss.hasPermi('manage:surgeryevent:list')")
    @GetMapping("/list")
    public TableDataInfo list(EventSurgery eventSurgery)
    {
        startPage();
        List<EventSurgery> list = eventSurgeryService.selectEventSurgeryList(eventSurgery);
        return getDataTable(list);
    }

    /**
     * 导出手术事件列表
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryevent:export')")
    @Log(title = "手术事件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EventSurgery eventSurgery)
    {
        List<EventSurgery> list = eventSurgeryService.selectEventSurgeryList(eventSurgery);
        ExcelUtil<EventSurgery> util = new ExcelUtil<EventSurgery>(EventSurgery.class);
        util.exportExcel(response, list, "手术事件数据");
    }

    /**
     * 获取手术事件详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryevent:query')")
    @GetMapping(value = "/{eventSurgeryId}")
    public AjaxResult getInfo(@PathVariable("eventSurgeryId") Long eventSurgeryId)
    {
        return success(eventSurgeryService.selectEventSurgeryByEventSurgeryId(eventSurgeryId));
    }

    /**
     * 新增手术事件
     */
    @ApiOperation("新增手术事件")
    @PreAuthorize("@ss.hasPermi('manage:surgeryevent:add')")
    @Log(title = "手术事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<EventSurgery> eventSurgerys)
    {

        eventSurgeryService.insertEventSurgery(eventSurgerys);
        return AjaxResult.success("操作成功");
    }

    /**
     * 修改手术事件
     */
    @ApiOperation("修改手术事件")
    @PreAuthorize("@ss.hasPermi('manage:surgeryevent:edit')")
    @Log(title = "手术事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EventSurgery eventSurgery)
    {
        return toAjax(eventSurgeryService.updateEventSurgery(eventSurgery));
    }

    /**
     * 删除手术事件
     */
    @ApiOperation("删除手术事件")
    @PreAuthorize("@ss.hasPermi('manage:surgeryevent:remove')")
    @Log(title = "手术事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{eventSurgeryIds}")
    public AjaxResult remove(@PathVariable Long[] eventSurgeryIds)
    {
        return toAjax(eventSurgeryService.deleteEventSurgeryByEventSurgeryIds(eventSurgeryIds));
    }
}
